# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.2.8

# 工作目录
WORKDIR /app/knowledge-base

# 复制打包文件
COPY .nitro/ deploy/.nitro/
COPY server/ deploy/server/
COPY bun.lock deploy/bun.lock
COPY bunfig.toml deploy/bunfig.toml
COPY nitro.config.ts deploy/nitro.config.ts
COPY package.json deploy/package.json
COPY tsconfig.json deploy/tsconfig.json

# 构建
## 前往构建目录
## 安装依赖
RUN cd deploy && bun install && bun run build
## 构建
RUN mkdir "/app/knowledge-base/runtime"
## 移动
RUN mv /app/knowledge-base/deploy/.output/* /app/knowledge-base/runtime/

# 挂载目录
## 数据库
VOLUME /app/knowledge-base/data
## 附件
VOLUME /app/knowledge-base/file

# 暴露端口
EXPOSE 13456/tcp

ENV NODE_ENV production
ENV PORT 13456

# 启动命令
ENTRYPOINT [ "bun", "run", "/app/knowledge-base/runtime/server/index.mjs" ]
